<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/taglibs.jsp"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>角色信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctxLayui}/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxLayui}/layuiadmin/style/myStyle.css" media="all">
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 10px 0 0;">
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">角色名称<span style="color:red">*</span></label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">排序<span style="color:red">*</span></label>
        <div class="layui-input-block">
            <input type="text" name="sortOrder" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">是否所有权限<span style="color:red">*</span></label>
        <div class="layui-input-block">
            <select name="hasAllRight" lay-verify="required" id="hasAllRight" lay-filter="hasAllRight">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-form-item-my" >
        <label class="layui-form-label">状态<span style="color:red">*</span></label>
        <div class="layui-input-block">
            <select name="status" lay-verify="required" id="status" lay-filter="status">
            </select>
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="添加">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="修改">
    </div>
</div>

<script src="${ctxLayui}/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '${ctxLayui}/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form','dict'], function(){

        var $ = layui.$
            ,form = layui.form;
        var admin = layui.admin;
        var dict = layui.dict;

        form.verify({
            roleName:function (value,item) {
                var params = {};
                var id = formData ? formData.id : null;
                if(id){
                    params.id = id;
                }
                params.name=value;
                var rtn = admin.syncReq(ctx+"/system/sysRole/checkRole",params);
                console.log("rtn....",rtn)
                if(rtn && rtn.data==-1){
                    return '角色名称['+value+']已存在'
                }
            }
        });

        var formData = window.parent.formData;
        dict.setSelect("status","status",formData?formData.status:1);
        dict.setSelect("hasAllRight","yesNot",formData?formData.hasAllRight:2);

    })
</script>
</body>
</html>